package cn.pn.project.client.order;

import cn.pn.project.client.order.fallback.OrderClientFallBack;
import cn.pn.project.config.DmConfiguration;
import cn.pn.project.pojo.order.Order;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 订单Client
 */
@FeignClient(name = "pn-order-provider", path="/OrderProvider",configuration = DmConfiguration.class/*,fallback = OrderClientFallBack.class*/)
public interface RestOrderClient {

    /**
     * 根据订单 Id/编号 查询订单信息
     * @RequestParam mainOrderId
     * @RequestParam orderNum
     * @return
     * @throws Exception
     */
    @PostMapping("/getOrderById")
    public Order getOrderById(@RequestParam(value = "mainOrderId",required = false)Integer mainOrderId, @RequestParam(value = "orderNum",required = false) String orderNum)throws Exception;

    /**
     * 多条件查询订单信息（分页）
     * @RequestParam RequestParam
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getOrderListByMap",method = RequestMethod.POST)
    public List<Order> getOrderListByMap(@RequestParam Map<String,Object> param)throws Exception;

    /**
     * 多条件查询订单数量
     * @RequestParam RequestParam
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getOrderCountByMap",method = RequestMethod.POST)
    public Integer getOrderCountByMap(@RequestParam Map<String,Object> param)throws Exception;

    /**
     * 新增订单信息
     * @param order
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/insertOrder",method = RequestMethod.POST)
    public Integer insertOrder(@RequestBody Order order)throws Exception;

    /**
     * 修改订单信息
     * @RequestParam order
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/updateOrder",method = RequestMethod.POST)
    public Integer updateOrder(@RequestBody Order order)throws Exception;

    /**
     * 删除订单(修改订单是否为删除状态)
     * @RequestParam mainOrderId
     * @RequestParam orderNum
     * @return
     */
    @RequestMapping(value = "/deleteOrderById",method = RequestMethod.POST)
    public Integer deleteOrderById(@RequestParam(value = "mainOrderId")Integer mainOrderId,@RequestParam(value = "orderNum") Integer orderNum)throws Exception;
}
